﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Text.RegularExpressions;
using System.Web.Mvc;
namespace DalatCooking.Core.Helper
{
    public class PagingHelper
    {
        public class PagingData<T>
        {
            public List<T> ListData { get; set; }
            public int PageSize { get; set; }
            public int PageNumber { get; set; }
            public int TotalRecords { get; set; }
            public int CurrentPage { get; set; }

            public int TotalPages
            {
                get { return (int)Math.Ceiling((decimal)this.TotalRecords / this.PageSize); }
            }
            /*
            public string Pager
            {
                get
                {
                    string link = "";

                    //  var totalPages = (TotalPages % PageSize == 0) ? TotalPages / PageSize : TotalPages / PageSize + 1;
                    var FistIndex = CurrentPage - 5;
                    var LastIndex = 0;
                    if (CurrentPage > 5)
                    {
                        LastIndex = CurrentPage + 5;
                    }
                    else
                    {
                        LastIndex = 10;
                    }
                    if (LastIndex > TotalPages)
                    {
                        LastIndex = TotalPages;
                        FistIndex = LastIndex - 10;
                    }
                    if (FistIndex < 1)
                    {
                        FistIndex = 1;
                    }

                    if (TotalPages >= 2)
                    {

                        if (CurrentPage != 1)
                        {
                            link += "<a href=" + 1 + "><span class=\"firstLink\">" + "" + "</span></a>";
                            link += "<a href=" + (CurrentPage - 1) + "><span class=\"prevLink\">" + "" + "</span></a>";
                        }
                        for (int i = FistIndex; i < LastIndex; i++)
                        {
                            if (i != CurrentPage)
                            {
                                link += " <a href=x" + i + ">" + i + "</a> ";


                            }
                            else
                            {
                                link += "<span class=\"active\">" + i.ToString() + "</span>";
                            }
                        }
                        if (CurrentPage != TotalPages)
                        {
                            link += " <a href=" + (CurrentPage + 1) + " class=\"nextLink\">" + "" + " </a>";
                            link += " <a href=" + TotalPages + " class=\"lastLink\">" + "" + " </a>";
                        }
                    }
                    return link;
                }
            }
        */
           
        }
       
    }
   
}
